❄️ PSYCH 413 Final Exam ❄️
Due Friday Dec 19th by 08:30 a.m.
General
- Please submit your responses as a nicely formatted notebook (.ipynb) file.
- If your answer includes many decimal places (e.g., 3.14159265358979), please round it to a reasonable number of decimals for readability (typically 3 to 4).
- For ease of marking, avoid showing the outputs of unnecessary values.
- Make sure your code runs without errors and shows all required outputs.
- Good coding style matters— clean, organized, and well-commented code will be rewarded. Disorganized, redundant, or poorly structured code may lose marks.
Requirements (IMPORTANT):
- Unless otherwise specified, set any trimming you need to do at 20% and use an \(\alpha = 0.05\).
- Unless the instructions explicitly state otherwise (e.g., “assume the data are normally distributed”), you are responsible for checking whether the assumptions of the method are reasonable and robust approaches need to be used.
- If classical test assumptions are not violated, use the classical test.
- Do not remove outliers unless explicitly asked to.
- Respect the principle of marginality.
Plots, Packages, and Functions:
- All plots must be made with ggplot2 and include clear, descriptive axis titles rather than default column names.
- Only the following packages are permitted:
tidyverse,WRS2,car
- Unless stated otherwise, The following functions are not permitted:
IQR,quantile(),mad(),t.test(),yuen(),trimse(),anova(),aov(),chisq.test()
Question 1
Many people mistakenly believe that behavioural change following punishment depends only on the severity of a consequence. In reality, the effectiveness of punishment procedures depends on more nuanced factors, including the degree of correlation between the response and the punisher (known as contingency) and the delay between the response and the punisher (known as contiguity).
The dataset phone_use_response_cost.csv examines the effects of contingency and delay on phone-use behaviour in students undergoing a classroom behaviour program. Each time a student used their phone during classroom hours, the student sometimes lost cellular and Wi-Fi access on their device for 1 hour (a negative punisher, because access to a valued resource was removed).
Independent Variables:
Punishment contingency was manipulated at four levels:
- 1.0 = High contingency (loss of connectivity always followed phone use)
- 0.75 = Medium contingency (loss of connectivity usually followed phone use)
- 0.25 = Low contingency (loss of connectivity sometimes followed phone use)
- 0 = No contingency (loss of connectivity was unrelated/unpredictable to phone use)
Importantly, all students experienced the same total number of one-hour connectivity losses across conditions; only the degree to which loss of connectivity was contingent on phone use varied.
Punishment delay was manipulated at four levels:
- 0 = Immediate (connectivity was removed immediately when the phone was used)
- 30s = Short delay (connectivity was removed 30 seconds after phone use)
- 60s = Moderate delay (connectivity was removed 60 seconds after phone use)
- 300s = Long delay (connectivity was removed 5 minutes after phone use)
Dependent Variable
The effectiveness of the program was measured using a suppression ratio, reflecting the extent to which students reduced their phone use during class relative to baseline. Lower suppression ratios indicate greater suppression of phone use (i.e., more effective punishment). Suppression ratios around 0.5 indicate no suppression.
Assume the data satisfy all the necessary assumptions for a classic 4 × 4 independent ANOVA.
Task
Create a professional-looking interaction plot for suppression ratio as a function of punishment contingency and punishment delay, including 95% confidence intervals.
Display a data frame showing the group means and corresponding confidence-interval boundaries on your plot.
Based on the plot, does the pattern of results suggest an interaction between punishment contingency and punishment delay?
Question 2
Using the phone_use_response_cost.csv data, fit a classic ANOVA model that predicts suppression ratio from both contingency and delay, including their interaction (i.e., a classic 4 × 4 factorial ANOVA).
The researchers were interested in a set of ordered, theory-driven contrasts for each independent variable, reflecting progressively finer distinctions in the effectiveness of their punishment method.
Contingency:
Maximal contingency hypothesis: Whether perfect contingency (1.00) produced greater suppression of phone use than the average of all lower contingency conditions (0.75, 0.25, 0).
Moderate contingency hypothesis: Whether high but imperfect contingency (0.75) produced greater suppression than the average of weak or absent contingency conditions (0.25, 0).
Minimal contingency hypothesis: Whether weak contingency (0.25) produced greater suppression than no contingency (0).
Delay:
Immediate punishment hypothesis: Whether immediate punishment (0 s) produced greater suppression of phone use than the average of all delayed punishment conditions (30, 60, 300 s).
Short vs long delay hypothesis: Whether a short delay (30 s) produced greater suppression than the average of longer delays (60 s, 300 s).
Long-delay differentiation hypothesis: Whether moderate (60 s) and long (300 s) delays differed in their effectiveness.
When creating your model (with interactions), set up custom contrasts that evaluate these hypotheses.
For each main effect and interaction, report the F-ratio, degrees of freedom, and p-value. For this question, all functions from allowed packages are permitted.
Question 3
Calculate an \(\omega^2\) effect size for the ANOVA’s effects. Do not round your outputs for this question, display as much precision as possible.
Given this and the previous question, describe your findings of the main effects and interaction.
Question 4
Are all the contrasts you created centered and orthogonal? Demonstrate your answer with R code, and display the table(s) of contrast values/weights used.
Question 5
Display the results table for your contrasts. Then, for each of the six hypotheses (main effects contrasts), state the conclusion you draw from these in plain English (i.e., without using numerical results).
Question 6
Considering the potential interactions, does a perfect contingency provide an advantage over weaker contingencies when the delay increases from moderate to long?
Report/extract the following:
- Test-statistic
- Degrees of freedom
- P-value
- Partial \(\eta^2\)
Question 7
A blogger named Josh Madison tabulated the amount of each M&M colour in a variety of M&M packages. The data can be found in MM_Madison.csv. Calculate a p-value to determine whether the data provide evidence that the colours are equally represented overall, or are some colours systematically more common than others across packages? Assume that the amount of each colour in a package is independent of the other colours.
Question 8
Assuming you calculated the previous question correctly, the test you conducted has a power of 0.98 to detect a small effect.
What does this imply about how the result of the hypothesis test should be interpreted? (You do not need to perform any additional calculations.)
Question 9
Holiday traditions often come with strong opinions (especially about candy). Some people swear that having a little holiday candy nearby makes stressful moments feel more manageable, while others think it’s just sugar and wishful thinking.
A local psychologist wanted to test whether having holiday candy available during a stressful task affects how anxious people feel.
To test this, participants were asked to complete a timed puzzle task in a softly lit room while a loop of chaotic “holiday mall music” played in the background (to create a mildly stressful, seasonally-themed atmosphere).
In one condition, a small plate of holiday sweets was beside them and they were told they could look at it but not eat it during the task. In the other condition, no candy was present.
During each session, the psychologist measured mean heart rate (in beats per minute) using a chest-strap monitor. Higher heart rate is presumed to indicate greater physiological arousal/anxiety.
The data file holiday_candy_hr.csv contains the following columns:
id— Unique random ID for each participant.condition— “Candy Present” or “No Candy”.hr_bpm— Heart rate (beats per minute) recorded during the task.
The researcher hypothesizes that the “No Candy” condition will produce higher levels of anxiety (i.e., higher heart rate) than the “Candy Present” condition. Conduct an appropriate statistical test to evaluate whether the data provide sufficient evidence to support the researcher’s hypothesis.
Report all of the following:
- Null and alternative hypothesis
- Test statistic
- Degrees of freedom
- p-value
- 95% confidence interval
Question 10
Create an appropriate bar plot to visualize the results from the previous question. Include two-sided 95% confidence intervals for each bar. Additionally, display a data frame containing the summary statistics shown in the plot.
Question 11
Over the years, several Alpine villages have reported a chilling pattern of wintertime disturbances during the Advent season. Local folklore attributes these events to Krampus, a legendary horned figure said to justly punish the wicked in the weeks leading up to Christmas. According to tradition, Krampus is most active during cold, dark nights, particularly when supernatural conditions are said to be strongest.
A group of cultural anthropologists and behavioural scientists has compiled a historical dataset of reported Krampus-related incidents from village records spanning 1890–2024. The dataset, krampus_incidents.csv, contains the following variables:
incident_severity: a continuous measure of severity of the incident developed by the researchers. It is on a scale of 0–100, where 100 indicates extreme harm or disruption.- snow_density: a continuous measure of snowfall intensity on the night of the incident (in % opacity, 0–100).
guard_exp_lvl: experience level of any village night guard present:- “None” (no guard present),
- “Novice” (inexperienced guard),
- “Experienced” (seasoned guard).
krampusnacht: categorical variable (Yes = 1, No = 0) indicating whether the incident occurred on Krampusnacht (December 5th), traditionally believed to be the peak of Krampus activity.
The researchers hypothesize that harsh environmental conditions (e.g., heavy snowfall) may increase the severity of incidents, particularly on Krampusnacht. They are also interested in whether the presence and experience level of village guards moderates these effects.
Your Task
Plot incident severity as a function of snow density, separately for incidents occurring on Krampusnacht and not on Krampusnacht.
Display separate OLS regression lines (incident_severity ~ snow_density) for Krampusnacht and non-Krampusnacht nights.
Format the plot to have a professional appearance suitable for inclusion in an academic article (because this is definitely real data you are analyzing).
If necessary, adjust the plot size to ensure optimal display within Google Colab.
Question 12
Using the krampus_incidents.csv data, create the following ordinary least-squares regression models using lm():
- Model 1:
- Predict incident severity as a function of snow density.
- Model 2:
- Extend Model 1 by adding the guard experiance level.
- Model 3:
- Extend Model 2 by adding Krampusnacht.
Use the following coding scheme for the categorical variables:
Guard Experiance:
| Level | \(X_2\) | \(X_3\) |
|---|---|---|
| None | 0 | 0 |
| Novice | 1 | 0 |
| Experienced | 0 | 1 |
Krampusnacht:
| Level | \(X_4\) |
|---|---|
| No | 0 |
| Yes | 1 |
Report each model’s equation, \(R^2\) value, and interpret the coefficients of the newely added predictor in plain English.
Question 13
Is there reason to think model 3 should be preferred over model 1? Conduct a test to evaluate this.
Question 14
Refit model 3 using ordinary least squares (lm()), after identifying and removing potential outliers with a robust outlier-detection method. List all observations that were removed, and report the fitted regression equation and its \(R^2\) value.
Question 15
Participants listened to an audio recording of an argument between two coworkers and were then asked: “How intense was the disagreement between the coworkers when they _______ with each other?”
The blank was filled with one of four verbs: “argued,” “disagreed”, “debated,” or “discussed.”
Participants responded by selecting one of three options: “very intense,” “moderately intense,” or “not very intense.”
The results are summarized in the following table:
| Very intense | Moderately intense | Not very intense | |
|---|---|---|---|
| Argued | 74 | 36 | 30 |
| Disagreed | 58 | 60 | 42 |
| Debated | 45 | 68 | 47 |
| Discussed | 26 | 44 | 80 |
Does the wording of the question (i.e., the verb used) significantly influence participants’ judgments of intensity?
Conduct an appropriate statistical test and report your conclusion, including the test statistic, degrees of freedom, and p-value.